package cn.xuchunh.campusbbs.adapter;

import android.content.Context;
import android.view.ViewGroup;

import cn.xuchunh.campusbbs.R;
import cn.xuchunh.campusbbs.base.BaseRecyclerViewAdapter;
import cn.xuchunh.campusbbs.bean.Topic;
import cn.xuchunh.campusbbs.utils.DateUtil;
import cn.xuchunh.campusbbs.viewholder.TopicViewHolder;

/**
 * Created by XuChunH on 2015/9/13.
 */
public class TopicListAdapter extends BaseRecyclerViewAdapter<TopicViewHolder, Topic> {

    public TopicListAdapter(Context context) {
        super(context);
        setNeedFooter(true);
    }

    @Override
    public TopicViewHolder onCreateContentViewHolder(ViewGroup parent, int viewType) {
        return new TopicViewHolder(inflater.inflate(R.layout.item_topic_list, parent, false));
    }

    @Override
    protected void onBindContentViewHolder(TopicViewHolder holder, int position) {
        Topic topic = dataList.get(position);
        holder.title.setText(topic.getTitle());
        holder.subject.setText(topic.getSubject());
        holder.date.setText(DateUtil.formatDate(topic.getLastReplyDate()));
        holder.nickName.setText(topic.getUserNickName());
        holder.hits.setText(topic.getHits() + "");
        holder.replies.setText(topic.getReplies() + "");
    }

}
